package com.shop.admin.controller;

import com.shop.admin.entity.ShopIngoods;
import com.shop.admin.result.ApiResult;
import com.shop.admin.service.ShopIngoodsService;
import com.shop.admin.utils.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

@Api(tags = {"RestockingController"},description = "库存记录页面所需接口")
@RestController
@RequestMapping("/api/restock")
public class RestockingController {

    @Resource
    private ShopIngoodsService ingoodsService;

//    @GetMapping("/list")
//    @ApiOperation(value = "获取进货列表",notes = "key")
//    public ApiResult list(@ApiParam("参数为key(进货人[1-黄梓航：2-何晓珑：3-陈浩生：4-陶依达：5-404一起])") @RequestParam Map<String, Object> params){
//        PageUtils page = ingoodsService.queryPageData(params);
//        return ApiResult.ok(page);
//    }
//
//    @PostMapping("/update")
//    @ApiOperation(value = "新增和修改进货列表",notes = "id,orderName,orderNum,purchasePrice,incomingPeople,commodityParametersone,commodityParameterstwo")
//    public ApiResult update(@ApiParam("参数为id,商品名字,商品数量,进价,进货人[1-黄梓航：2-何晓珑：3-陈浩生：4-陶依达：5-404一起],商品参数1,商品参数2")
//                            @RequestBody ShopIngoods ingoods){
//        ShopIngoods shopIngoods = new ShopIngoods();
//        BeanUtils.copyProperties(ingoods,shopIngoods);
//        if (ingoods.getId()==null) {
//            shopIngoods.setCreateTime(new Date());
//        }
//        shopIngoods.setUpdateTime(new Date());
//        ingoodsService.saveOrUpdate(shopIngoods);
//        return ApiResult.ok("操作成功");
//    }
//
//    @GetMapping("/delete")
//    @ApiOperation(value = "删除",notes = "id")
//    public ApiResult delete(@ApiParam("参数为id")
//                            @RequestParam("id") Integer id){
//        ingoodsService.removeById(id);
//        return ApiResult.ok("删除成功");
//    }

}
